#pragma once
#include <d3dx9.h>
#include <string>
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)

class EventPlace;

/**
@brief XRectangle 3D3
Representation 3D d'un album
*/
class XRectangle
{
	struct CUSTOMVERTEX
	{
		D3DXVECTOR3 position; // The position
		D3DCOLOR    color;    // The color
		FLOAT       tu, tv;   // The texture coordinates
	};

	///Position courante
	float _x;
	///Inclinaison courante
	float _rot;
	///Position demande
	float _tx;
	///Rotation demande
	float _trot;
	///Nombre de transition
	int _iTrans;
	///Pas de deplacement en x
	float _txStep;
	///Pas de rotation
	float _trotStep;
	///A effacer ?
	bool _bToDel;

	/// Buffer to hold vertices
	LPDIRECT3DVERTEXBUFFER9 _pVB;
	/// Buffer to hold vertices mirorring
	LPDIRECT3DVERTEXBUFFER9 _pVB2; 
	/// Pointeur to D3D texture
	LPDIRECT3DTEXTURE9      _pTexture;
	/// Nom du fichier de texture
	std::wstring _filename;
	///???
	EventPlace* _pEventPlace;	
public:
	XRectangle();
	~XRectangle(void);
	HRESULT create(LPDIRECT3DDEVICE9 pDevice);
	HRESULT loadTexture(LPDIRECT3DDEVICE9 pDevice);
	void setImgFilename(const wchar_t *filename);
	void draw(LPDIRECT3DDEVICE9 pDevice);
	void set( const float& x, const float& rot);
	void get( float& x, float& rot ) const;
	void setToGo( const XRectangle* pRect );
	void set( const XRectangle* pRect );
	void translate(LPDIRECT3DDEVICE9 pDevice);
	void setEvent(EventPlace *pEvent);
};

